/******************************************************************************
** @file	test_cm_shareitem.cpp
** @author  Joel Chuca
**
** @date	Sep 01, 2010
**
** @desc	This testSuite tests the insertion and selection of wmi share objects
*			
******************************************************************************/

#include "unit--/unit--.h"
#include "cm_dblitemanager.h"
#include "adcm_computer.h"
#include "wmi_share.h"
#include "wmi_result.h"

#include <string>
#include <vector>
#include "cm_shareitem.h"
#include "cm_dblitemanager.h"
#include "cm_resultcollection.h"

using namespace std;
using namespace unit_minus;

testSuite(CacheManager);

testCase(getSharesListTest, CacheManager)
{
    cout << "----- Start getSharesListTest -----" << endl;
    WMI_Result<WMI_Share> resultShares ;
    CM_ShareItem shareItem;
    int res = shareItem.getShares(1, resultShares);

    assertTrue( res == 1);
    cout << "-------- End insertComputersTest ------" << endl;
}

testCase(insertShareListTest, CacheManager)
{
    cout << "----- Start insertShareListTest -----" << endl;
    CM_DBLiteManager mng ;
    mng.initialize();
    
    WMI_Share* share1 = new WMI_Share;
    share1->setAccessMask(1111);
    share1->setAllowMaximum(false);
    wstring aux = L"notepad.exe";
    share1->setCaption(aux);
    share1->setDescription(wstring(L"This is a description"));
    share1->setInstallDate(CTime(1092941466));
    share1->setMaximumAllowed(111);
    share1->setName(wstring(L"notepad"));
    share1->setPath(wstring(L"c:\\Archivos de programa"));
    share1->setStatus(wstring(L"ok"));
    share1->setType(1);

    WMI_Share* share2 = new WMI_Share;
    share2->setAccessMask(1111);
    share2->setAllowMaximum(true);
    share2->setCaption(wstring(L"visual studio.exe"));
    share2->setDescription(wstring(L"This is a description"));
    share2->setInstallDate(CTime(1092941466));
    share2->setMaximumAllowed(111);
    share2->setName(wstring(L"notepad"));
    share2->setPath(wstring(L"c:\\Archivos de programa"));
    share2->setStatus(wstring(L"ok"));
    share2->setType(1);
    
    WMI_Result<WMI_Share> resultShares ;
    resultShares.getObjects().push_back(share1);
    resultShares.getObjects().push_back(share2);

    /*vector<WMI_Share*> resulVec = resultShares.getObjects();

    for(vector<WMI_Share*>::const_iterator it = resulVec.begin(); it != resulVec.end(); it++ )
    {
        wcout << L"caption: " << (*it)->getCaption() << endl;        
    }*/

    CM_ShareItem shareItem;
    int res = shareItem.saveShares(1, resultShares);
    assertTrue(res == 1);

    cout << "-------- End insertComputersTest ------" << endl;
}